package com.kfm.jdbc.day0405;

public class Demo06 {

    public static void main(String[] args) {
        MyThread1 t1 = new MyThread1();
        MyThread2 t2 = new MyThread2();
        t1.start();
        t2.start();
    }
}

class MyThread1 extends Thread{

    // 余额
    public volatile static int money = 10000;

    @Override
    public void run() {
        while(money == 10000) {

        }
        System.out.println("我的余额变了");
    }

}

class MyThread2 extends Thread{

    @Override
    public void run() {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("我要修改余额");
        MyThread1.money = 1;
    }
}
